import axios from "axios"
import { ElMessage } from "element-plus"

const requestInstance = axios.create({
  baseURL: '/api/',
  timeout: 100000,
  headers: {  
    'Content-Type': 'application/json', // 设置请求头
  },  
})

requestInstance.interceptors.request.use(
  (config) => {
    // config.headers.Authorization = `Bearer ${token}`; 
    return config
  },
  (error) => {
    return Promise.reject(error); 
    // ElMessage.error(error)
  }
)

requestInstance.interceptors.response.use(
  (response) => {
    return response?.data
  },
  (error) => {
    return Promise.reject(error); 

    // ElMessage.error(error)
  }
)

export default requestInstance